home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / BIOLOGY / BIOMRF.ZIP / BIOMRF.BAS < prev    next >
BASIC Source File  |  1988-11-09  |  5KB  |  162 lines

  1. CLS
  2.  
  3. print"╔═══════════════════════════════════════════════════════════════════════════╗"
  4. print"║                                                                           ║"
  5. print"║                                 BIOMURFFS                                 ║"
  6. print"║                                 ─────────                                 ║"
  7. print"║                                                                           ║"
  8. print"║                                VERSION 1.3                                ║"
  9. print"║                                                                           ║"
  10. print"║                                D.J. Murphy                                ║"
  11. print"║                               12th May 1988                               ║"
  12. print"╟───────────────────────────────────────────────────────────────────────────╢"
  13. print"║                                                                           ║"
  14. print"║                                                                           ║"
  15. print"║ This program is based  on the one  Richard Dawkins  describes in his book ║"
  16. print"║ 'The Blind Watchmaker'. If you want to know  what each bit does, read the ║"
  17. print"║ file  'BIO.DOC'  which will  describe  how  the data is  coded and  used. ║"
  18. print"║ If, however, you just want to see  the computer drawing  pretty patterns, ║"
  19. print"║ the questions you are  asked in the program are self explanatory once you ║"
  20. print"║ get going. In order to get the hang of it, use the default starting genes ║"
  21. print"║ which    means    replying   N   to    the    second    two    questions. ║"
  22. print"║                                                                           ║"
  23. print"╚═══════════════════════════════════════════════════════════════════════════╝"
  24.  
  25.  
  26. ' Subroutine MAIN
  27. ' This is the main segment of the biomurff program, controlling the operation
  28. ' of the other routines
  29.  
  30. option base 1
  31.  
  32. dim biomorphs%(16,9), posns%(2048,4)
  33.  
  34. locate 23,3
  35. input"Do you have a printer connected ";reply$
  36. if ucase$(left$(reply$,1)) = "Y" then shell "graphics"
  37.  
  38. locate 23,3
  39. input"Do you want to define the initial gene values yourself ";reply$
  40. cls
  41. screen 2
  42. if ucase$(left$(reply$,1)) = "Y" then
  43.  
  44.     print"The genes control biomorph phenotypes as follows:"
  45.         print
  46.     print"1: # of offspring"
  47.     print"2: # of iterations in drawing"
  48.     print"3: branch length 1"
  49.     print"4: branch length 2"
  50.     print"5: branch length combination"
  51.     print"6: angle (degrees) of 1st branch from stem"
  52.     print"7: angle (degrees) of 2nd branch from 1st"
  53.     print"8: length of initial branch"
  54.         print
  55.  
  56.     for bio% = 1 to 8
  57.         print"Gene ";bio%;
  58.         input" Value ";biomorphs%(1,bio%)
  59.     next bio%
  60.  
  61. else
  62.  
  63.     print"The default initial values are:"
  64.     print"6,2,8,1,2,135,90,10"
  65.     print
  66.     input"Do you want these or a random selection ";reply$
  67.     if ucase$(left$(reply$,1)) = "R" then
  68.  
  69.         randomize timer
  70.         
  71.         biomorphs%(1,1) = int(rnd * 16) + 1
  72.         biomorphs%(1,2) = int(rnd * 8)
  73.         biomorphs%(1,3) = int(rnd * 8) + 1
  74.         biomorphs%(1,4) = int(rnd * 8) + 1
  75.         biomorphs%(1,5) = int(rnd * 2) + 1
  76.         biomorphs%(1,6) = int(rnd * 360) + 1
  77.         biomorphs%(1,7) = int(rnd * 360) + 1
  78.         biomorphs%(1,8) = int(rnd * 50) + 1
  79.         for bio% = 1 to 8
  80.         
  81.             print bio%;": ";biomorphs%(1,bio%)
  82.         
  83.         next bio%
  84.  
  85.     else
  86.  
  87.         biomorphs%(1,1) = 6
  88.         biomorphs%(1,2) = 2
  89.         biomorphs%(1,3) = 8
  90.         biomorphs%(1,4) = 1
  91.         biomorphs%(1,5) = 2
  92.         biomorphs%(1,6) = 135
  93.         biomorphs%(1,7) = 90
  94.         biomorphs%(1,8) = 10
  95.         print"Default values used"
  96.     
  97.     end if
  98.  
  99. end if
  100. print
  101. print"To end at any point, just press RETURN on it's own to the"
  102. print"'Which biomorph do you want ?' prompt."
  103. print
  104.  
  105. for bio% = 1 to 8
  106.     for popn% = 2 to biomorphs%(1,1)
  107.         biomorphs%(popn%,bio%) = biomorphs%(1,bio%)
  108.     next popn%
  109. next bio%
  110.  
  111. input"Press RETURN to show this biomorph ";reply$
  112. cls
  113. popn% = 1
  114.  
  115. call bioplot(posns%(),biomorphs%(),popn%)
  116.  
  117. locate 1,1
  118. input"Press RETURN to start ";reply$
  119. popn% = biomorphs%(1,1)
  120. cls
  121.  
  122. do
  123.  
  124.     call mutate(biomorphs%(),popn%)
  125.     call bioplot(posns%(),biomorphs%(),popn%)
  126.     do
  127.         locate 1,1
  128.                 print"                                                               "
  129.                 locate 1,1
  130.             input"Do you want to see any of these alone ";reply$
  131.         if ucase$(left$(reply$,1)) = "Y" then
  132.                 do
  133.                     locate 1,1
  134.                     print"                                                       "
  135.                     locate 1,1
  136.                     input"Which one do you want ";choice%
  137.                  loop until choice% >= 1 and choice% <= popn%
  138.                  cls
  139.                 call bp2(posns%(),biomorphs%(),choice%)
  140.                     locate 1,1
  141.                     print"                                            "
  142.                     locate 1,1
  143.                     input"Press RETURN to continue ";rep$
  144.                     cls
  145.             call bioplot(posns%(),biomorphs%(),popn%)
  146.         end if
  147.     loop until ucase$(left$(reply$,1)) <> "Y"
  148.  
  149.     call choose(biomorphs%(),popn%)
  150.     popn% = biomorphs%(1,1)
  151.         cls
  152.  
  153. loop until popn% = 0
  154.  
  155. end
  156.  
  157. $INCLUDE"BIOPLOT.INC"
  158. $INCLUDE"VTRPLOT.INC"
  159. $INCLUDE"SELECT.INC"
  160. $INCLUDE"MUTATE.INC"
  161. $INCLUDE"BP2.INC"
  162.